package com.symaster.common.entity;

import java.io.Serializable;

/**
 * @author yinmiao
 * @date 2021-05-18 11:20
 */
public class Result implements Serializable {
    public static final Integer SUCCESS = 200;
    public static final Integer ERROR = 300;
    public static final Integer LOGIN_ERROR = 600;
    public static final String SUCCESS_STR = "success";
    public static final String ERROR_STR = "error";
    public static final String LOGIN_ERROR_STR = "loginError";
    private static final long serialVersionUID = -6849794470754667710L;
    /**
     * 返回代码
     */
    private Integer code;
    /**
     * 返回消息
     */
    private String message;
    /**
     * 返回数据
     */
    private Object data;

    public Result(Integer code, String message, Object data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }

    public static Result success() {
        return new Result(SUCCESS, SUCCESS_STR, null);
    }

    public static Result success(String message) {
        return new Result(SUCCESS, message, null);
    }

    public static Result success(Object object) {
        return new Result(SUCCESS, SUCCESS_STR, object);
    }

    public static Result success(String message, Object object) {
        return new Result(SUCCESS, message, object);
    }

    public static Result error() {
        return new Result(ERROR, ERROR_STR, null);
    }

    public static Result error(String message) {
        return new Result(ERROR, message, null);
    }

    public static Result loginError() {
        return new Result(LOGIN_ERROR, LOGIN_ERROR_STR, null);
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }
}
